// GoPlayer.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "board.h"
//#include "uctnode.h"
#include "time.h"
#include "chrono.h"
#include <windows.h>


//bool simpleKoRule (Board currentBoard, int posx, int posy)

void _tmain(int argc, _TCHAR* argv[])
{
	/* initialize random seed: */
	srand ( time(NULL) );

	Board* b = new Board(9);
	//int size = b->getSize();
		
	b->setWhite(0,0);b->setBlack(0,6);b->setBlack(0,8);
	b->setWhite(1,1);b->setBlack(1,7);
	b->setWhite(2,0);b->setBlack(2,2);b->setBlack(2,3);b->setBlack(2,4);
	b->setBlack(3,2);b->setBlack(3,3);
	b->setBlack(4,2);b->setBlack(4,3);b->setBlack(4,4);b->setBlack(4,5);
	b->setBlack(5,2);b->setBlack(5,3);b->setBlack(5,4);b->setBlack(5,5);b->setWhite(5,6);b->setWhite(5,7);b->setWhite(5,8);
	b->setBlack(6,0);b->setBlack(6,1);b->setBlack(6,2);b->setBlack(6,3);b->setWhite(6,6);b->setWhite(6,8);
	b->setWhite(7,0);b->setWhite(7,1);b->setWhite(7,2);b->setBlack(7,3);b->setWhite(7,6);b->setWhite(7,7);b->setWhite(7,8);
	b->setWhite(8,2);b->setBlack(8,3);b->setWhite(8,6);
	/*b->setLabel();
	b->checkIfAlive();
	b->displayBoard();
	Board* c= new Board(b);
	size = c->getSize();
	for(int i=0; i<size; i++) 
        for(int j=0; j<size; j++)
			if (c->isEmpty(i,j))
				c->setWhite(i,j);
	c->setLabel();
	c->checkIfAlive();
	c->displayBoard();
	b->capture();
	b->displayBoard();
	while(1);*/
	/*b->setWhite(0,0);b->setWhite(0,1);b->setWhite(0,2);b->setWhite(0,3);b->setWhite(0,4);b->setWhite(0,5);b->setWhite(0,6);b->setWhite(0,7);b->setWhite(0,8);
	b->setWhite(1,0);b->setWhite(1,1);b->setWhite(1,2);b->setWhite(1,3);b->setWhite(1,4);b->setWhite(1,5);b->setWhite(1,6);b->setWhite(1,7);b->setWhite(1,8);
	b->setWhite(2,0);b->setWhite(2,1);b->setWhite(2,2);b->setWhite(2,3);b->setWhite(2,4);b->setWhite(2,5);b->setWhite(2,6);b->setWhite(2,7);b->setWhite(2,8);
	b->setWhite(3,0);b->setWhite(3,1);b->setWhite(3,2);b->setWhite(3,3);b->setWhite(3,4);b->setWhite(3,5);b->setWhite(3,6);b->setWhite(3,7);b->setWhite(3,8);
	b->setWhite(4,0);b->setWhite(4,1);b->setWhite(4,2);b->setWhite(4,3);b->setWhite(4,4);b->setWhite(4,5);b->setWhite(4,6);b->setWhite(4,7);b->setWhite(4,8);
	b->setWhite(5,0);b->setWhite(5,1);b->setWhite(5,2);b->setWhite(5,3);b->setWhite(5,4);b->setWhite(5,5);b->setWhite(5,6);b->setWhite(5,7);b->setWhite(5,8);
	b->setWhite(6,0);b->setWhite(6,1);b->setWhite(6,2);b->setWhite(6,3);b->setWhite(6,4);b->setWhite(6,5);b->setWhite(6,6);b->setWhite(6,7);b->setWhite(6,8);
	b->setWhite(7,0);b->setWhite(7,1);b->setWhite(7,2);b->setWhite(7,3);b->setWhite(7,4);b->setWhite(7,5);b->setWhite(7,6);b->setWhite(7,7);b->setWhite(7,8);
	b->setWhite(8,0);b->setWhite(8,1);b->setWhite(8,2);b->setWhite(8,3);b->setWhite(8,4);b->setWhite(8,5);b->setWhite(8,6);b->setWhite(8,7);b->setWhite(8,8);*/

	/*b->setBlack(0,1);b->setWhite(0,2);b->setWhite(0,4);b->setWhite(0,6);b->setWhite(0,7); //PROB EX
	b->setBlack(1,0);b->setBlack(1,1);b->setWhite(1,2);b->setWhite(1,3);b->setWhite(1,4);b->setWhite(1,5);b->setWhite(1,6);b->setBlack(1,7);b->setWhite(1,8);
	b->setWhite(2,0);b->setWhite(2,1);b->setBlack(2,2);b->setBlack(2,3);b->setBlack(2,4);b->setBlack(2,5);b->setBlack(2,6);b->setBlack(2,7);b->setBlack(2,8);
	b->setWhite(3,2);b->setBlack(3,3);b->setBlack(3,4);b->setBlack(3,5);b->setWhite(3,6);b->setBlack(3,7);
	b->setWhite(4,0);b->setWhite(4,1);b->setWhite(4,2);b->setBlack(4,3);b->setBlack(4,4);b->setBlack(4,5);b->setWhite(4,6);b->setBlack(4,7);b->setBlack(4,8);
	b->setWhite(5,0);b->setWhite(5,1);b->setBlack(5,2);b->setBlack(5,3);b->setWhite(5,4);b->setBlack(5,5);b->setWhite(5,6);b->setBlack(5,7);b->setBlack(5,8);
	b->setWhite(6,1);b->setBlack(6,2);b->setBlack(6,3);b->setWhite(6,4);b->setBlack(6,5);b->setWhite(6,6);b->setBlack(6,7);b->setBlack(6,8);
	b->setWhite(7,0);b->setWhite(7,1);b->setWhite(7,2);b->setWhite(7,3);b->setWhite(7,4);b->setWhite(7,5);b->setWhite(7,6);b->setBlack(7,7);
	b->setWhite(8,1);b->setWhite(8,2);b->setWhite(8,3);b->setWhite(8,5);b->setBlack(8,6);b->setBlack(8,7);b->setBlack(8,8);*/

	/*b->setBlack(0,0);b->setBlack(0,1);b->setBlack(0,2);b->setBlack(0,3);b->setBlack(0,5);b->setBlack(0,6);b->setBlack(0,7);b->setBlack(0,8);	//PROB EX ko
	b->setWhite(1,0);b->setBlack(1,1);b->setBlack(1,2);b->setBlack(1,3);b->setBlack(1,4);b->setBlack(1,5);b->setBlack(1,6);b->setWhite(1,7);b->setBlack(1,8);
	b->setWhite(2,1);b->setBlack(2,2);b->setBlack(2,3);b->setWhite(2,4);b->setWhite(2,5);b->setWhite(2,6);b->setWhite(2,8);
	b->setWhite(3,0);b->setWhite(3,1);b->setWhite(3,2);b->setWhite(3,3);b->setWhite(3,4);b->setBlack(3,5);b->setWhite(3,6);b->setWhite(3,7);b->setWhite(3,8);
	b->setBlack(4,0);b->setBlack(4,1);b->setBlack(4,2);b->setBlack(4,3);b->setBlack(4,4);b->setBlack(4,5);b->setWhite(4,6);b->setWhite(4,7);b->setWhite(4,8);
	b->setWhite(5,0);b->setBlack(5,1);b->setBlack(5,2);b->setBlack(5,3);b->setBlack(5,4);b->setBlack(5,5);b->setBlack(5,6);b->setWhite(5,7);b->setWhite(5,8);
	b->setWhite(6,0);b->setWhite(6,1);b->setWhite(6,2);b->setBlack(6,3);b->setWhite(6,4);b->setWhite(6,5);b->setBlack(6,6);b->setBlack(6,7);b->setBlack(6,8);
	b->setWhite(7,0);b->setWhite(7,2);b->setWhite(7,3);b->setWhite(7,4);b->setWhite(7,6);b->setBlack(7,7);
	b->setWhite(8,1);b->setWhite(8,2);b->setWhite(8,4);b->setWhite(8,5);b->setWhite(8,6);b->setBlack(8,7);b->setBlack(8,8);*/

	/*b->setWhite(0,0);b->setWhite(0,1);b->setWhite(0,2);b->setWhite(0,3);b->setWhite(0,4);b->setWhite(0,5);b->setWhite(0,6);b->setWhite(0,7);b->setWhite(0,8);
	b->setWhite(1,0);b->setWhite(1,1);b->setWhite(1,2);b->setWhite(1,3);b->setWhite(1,4);b->setWhite(1,5);b->setWhite(1,6);b->setWhite(1,7);b->setWhite(1,8);
	b->setWhite(2,0);b->setWhite(2,1);b->setWhite(2,2);b->setWhite(2,3);b->setWhite(2,4);b->setWhite(2,5);b->setWhite(2,6);b->setWhite(2,7);b->setWhite(2,8);
	b->setWhite(3,0);b->setWhite(3,1);b->setWhite(3,2);b->setWhite(3,3);b->setWhite(3,4);b->setWhite(3,5);b->setWhite(3,6);b->setWhite(3,7);b->setWhite(3,8);
	b->setWhite(4,0);b->setWhite(4,1);b->setWhite(4,2);b->setWhite(4,3);b->setWhite(4,4);b->setWhite(4,5);b->setWhite(4,6);b->setWhite(4,7);b->setWhite(4,8);
	b->setWhite(5,0);b->setWhite(5,1);b->setWhite(5,2);b->setWhite(5,3);b->setWhite(5,4);b->setWhite(5,5);b->setWhite(5,6);b->setWhite(5,7);b->setWhite(5,8);
	b->setWhite(6,0);b->setWhite(6,1);b->setWhite(6,2);b->setWhite(6,3);b->setWhite(6,4);b->setWhite(6,5);b->setWhite(6,6);b->setWhite(6,7);b->setWhite(6,8);
	b->setWhite(7,0);b->setWhite(7,1);b->setWhite(7,2);b->setWhite(7,3);b->setWhite(7,4);b->setWhite(7,5);b->setWhite(7,6);b->setWhite(7,7);b->setWhite(7,8);
	b->setWhite(8,0);b->setWhite(8,1);b->setWhite(8,2);b->setWhite(8,3);b->setWhite(8,4);b->setWhite(8,5);b->setWhite(8,6);b->setWhite(8,7);b->setWhite(8,8);*/

	//b->displayBoard();
	//b->playGame();
	b->playGame(BLACK);

	/*time_t start,end;
	double dif;
	time (&start); */
	
	
	/*Chrono t;
	int white=0,black=0,c=1;
	t.iGo();
	for (int i=0 ; i<100 ; i++) {
		if (b->launchMonteCarlo(WHITE,0,0,-1,-1))
			black++;
		else
			white++;
		printf("End of Game %i\n",c++);
		//Sleep(2000);
	}
	/*time (&end);
	dif = difftime (end,start);*/
	//printf("Black won %i times, White won %i times.\n",black ,white);
	//printf ("It took %.2lf seconds.\n", dif );
	//printf("It took : %d ms.\n",t.iStop());

	
	delete b;
	while (1);
}